# Contributor: Mark Pashmfouroush <mark@markpash.me>
# Maintainer: Kevin Daudt <kdaudt@alpinelinux.org>
pkgname=corerad
pkgver=1.3.1
pkgrel=0
pkgdesc="Extensible and observable IPv6 Neighbor Discovery Protocol router advertisement daemon"
url="https://corerad.net/"
license="Apache-2.0"
arch="all"
options="net" # Requires net for getting go module dependencies
makedepends="go"
install="$pkgname.pre-install"
subpackages="$pkgname-openrc"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/mdlayher/corerad/archive/v$pkgver.tar.gz
	corerad.initd
	"

# access denied for ipv6 autoconfiguration
[ "$CARCH" = "s390x" ] && options="$options !check"

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	make VERSION="$pkgver"

	# create a minimal configuration file
	./cmd/corerad/corerad -init
}

check() {
	go test ./...
}

package() {
	install -Dm755 cmd/corerad/corerad "$pkgdir"/usr/sbin/corerad

	install -Dm755 "$srcdir"/corerad.initd "$pkgdir"/etc/init.d/corerad
	install -Dm644 corerad.toml "$pkgdir"/etc/corerad/config.toml
}

sha512sums="
616003e710a669a77127d9be10a21e12af9f1de744dc1583c58a594ef38fb83108d4b4c4ffeabcf2a4ff0418cb53c7c96aae7b980900624d36df751e9ef657fc  corerad-1.3.1.tar.gz
f0e6249e2430a6b1d3d826fd5dd4e9df936af4d21ad9d42c6655b28c92847a2ae41874c313bc054fa3067915d7af02769794f3fb4d2ce70b47c029793da7dd76  corerad.initd
"
